<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/conn_db.php");?>
<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/Util.php");?>
<?php //DB Open

	$result = null;
	$db = new MyDB ( false );
	$db->err_report = true;

?>
<?php

	$util = new Util();

	$left = $_POST['left'];
	$right = $_POST['right'];

	if( $left && $right ){

		$sql = ' SELECT category_name, category_hanja, category_history1 FROM tb_category  WHERE category_lft='.$left.' AND category_rgt='.$right;
		$db->query ( $sql );
		$result = $db->result;
		$row = mysql_fetch_object($result);

		$result = null;
		$sql = ' SELECT category_name, category_hanja, category_sid FROM tb_category  WHERE category_lft BETWEEN '.($left+1).' AND '.($right-1).' ORDER BY category_lft ASC;';
		$db->query ( $sql );
		$result = $db->result;
		$total = mysql_num_rows ($result);
	}
?>
<?php //DB Close

	$db->close ();

?>
<table width="954" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td style="padding-bottom:10px;"><table width="954" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td><table width="954" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="10"><img src="img/surn/cont_bg08.jpg" width="10" height="36"></td>
			  <td align="center" background="img/surn/cont_bg10.jpg" class="text04"><strong><?php echo $row->category_name;?>(<?php echo $row->category_hanja;?>)씨 총설</strong></td>
			  <td width="10"><img src="img/surn/cont_bg09.jpg" width="10" height="36"></td>
			</tr>
		</table></td>
	  </tr>
	  <tr>
		<td valign="top" background="img/surn/cont_bg15.jpg" class="text02" style="padding:10px 10px 2px 10px;"><?php echo $row->category_history1;?></td>
	  </tr>
	  <tr>
		<td><table width="954" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="10"><img src="img/surn/cont_bg11.jpg" width="10" height="10"></td>
			  <td height="10" background="img/surn/cont_bg13.jpg"><img src="img/surn/cont_bg13.jpg" width="10" height="10"></td>
			  <td width="10"><img src="img/surn/cont_bg12.jpg" width="10" height="10"></td>
			</tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table width="954" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td><table width="954" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="10"><img src="img/surn/cont_bg08.jpg" width="10" height="36"></td>
			  <td valign="bottom" background="img/surn/cont_bg10.jpg" class="text04" style="padding-left:8px;"><img src="img/surn/cont_img03.jpg" width="192" height="22"></td>
			  <td width="10"><img src="img/surn/cont_bg09.jpg" width="10" height="36"></td>
			</tr>
		</table></td>
	  </tr>
	  <tr>
		<td valign="top" background="img/surn/cont_bg15.jpg" class="text05" style="padding:10px 14px 0 14px;">
		  <?php if($total>0):?>
			<?php $i=0;?>
			<?php while($list = mysql_fetch_object($result)):?>
				<?php if($i%9==0):?>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					  <tr>
				<?php endif;?>
						<td <?php if($i%9!=8):?>width="104"<?php endif;?> height="32" valign="top"><table width="94" height="26" border="0" cellpadding="0" cellspacing="0">
						  <tr>
							<td align="center" background="img/surn/cont_img11.jpg" class="text05"> <a href="surn01_01.php?sid=<?php echo $list->category_sid;?>"><strong><?php echo $list->category_name;?><?php if(11 > strlen($list->category_hanja)) echo "(".$list->category_hanja.")";?></strong></a></td>
						  </tr>
						</table></td>
				<?php if($i%9==8):?>
					  </tr>
					</table>
				<?php endif;?>
				<?php $i++;?>
			<?php endwhile;?>
		  <?php endif;?>
		  <?php if($i%9!=0):?>
		    <?php for ( $j=0; $j<9-($i%9); $j++) :?>
				<td <?php if($j<8-($i%9)):?>width="104"<?php endif;?> height="32" valign="top">&nbsp;</td>
			<?php endfor;?>
			  </tr>
			</table>
		  <?php endif;?>
		</td>
	  </tr>
	  <tr>
		<td><table width="954" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="10"><img src="img/surn/cont_bg11.jpg" width="10" height="10"></td>
			  <td height="10" background="img/surn/cont_bg13.jpg"><img src="img/surn/cont_bg13.jpg" width="10" height="10"></td>
			  <td width="10"><img src="img/surn/cont_bg12.jpg" width="10" height="10"></td>
			</tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
</table>
